# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  include AuthenticatedSystem

  helper :all # include all helpers, all the time

  helper_method :current_user, :logged_in?, :admin?, :last_active

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => '85617fcfe5f9963e2883447aac35ab99'
  
  # See ActionController::Base for details 
  # Uncomment this to filter the contents of submitted sensitive data parameters
  # from your application log (in this case, all fields with names like "password"). 
  # filter_parameter_logging :password


  private

  def redirect_to_index(msg = nil)
    flash[:notice] = msg if msg
    redirect_to :action => :index
  end

  #START:find_cart
  def find_cart
    @cart = (session[:cart] ||= Cart.new)
  end
  #END:find_cart<

  def find_user
    @user = User.find(session[:user_id])
  end
end
